/*
*  Copyright 2012 m4f10
*
*  This file is part of uScan.
*  uScan is free software: you can redistribute it and/or modify it under the
*  terms of the GNU General Public License as published by the 
*  Free Software Foundation, either version 3 of the License, or (at your option)
*  any later version.
*
*    uScan is distributed in the hope that it will be useful, 
*    but WITHOUT ANY WARRANTY; without even the implied warranty of 
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
* 
*    See the GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License 
*    along with uScan. If not, see http://www.gnu.org/licenses/.
*/

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package uscan;

/**
 *
 * @author m4f10
 */
public class UScanThread extends Thread  {
    
    boolean        thrd_found;
    public String thrd_param;
    protected UScanThread thread;
    private final int THREAD_IDLE = 0;
    private final int THREAD_VERIFY_REG = 1;
    private final int THREAD_VERIFY_VAL = 2;
    private final int THREAD_VERIFY_ARR = 3;
    
    
    public UScanCore  uscan;
    public UScanThread()
    {   
        
    }
    // Thread-only callable function!
    @Override
    public void run() 
    {

        this.thrd_found = threadExecuteOP(this.thrd_param);
        
    }
    public void main(UScanCore uscan, String param) {
        thread = this;
        initThreading(uscan,param);
        thread.start();

    }
    public void initThreading(UScanCore s, String param)
    {
        this.uscan = s;
        this.thrd_param = param;
    }
    
    private boolean threadExecuteOP(String param)
    {
        boolean ret=false;
    switch(this.uscan.current_op)
    {
        case THREAD_VERIFY_REG:
            ret=uscan.VerifyGet(uscan.original_src,param);
        break;
        case THREAD_VERIFY_VAL:
            ret=uscan.VerifyGetWithValue(uscan.original_src,param);    
        break;
        case THREAD_VERIFY_ARR:
            ret=uscan.VerifyGetWithArray(uscan.original_src,param);    
        break;
        
    }
        System.out.println("Mot: "+param+"||| "+ret);
        return ret;
    }
    
}
